<template>
  <el-form :inline="true" size="small" :model="query">
    <!-- 搜索 -->
    <el-form-item label="课程名称">
      <el-input v-model="query.name" clearable placeholder="输入课程名称搜索" @keyup.enter.native="toQuery"/>
    </el-form-item>
    <el-form-item>
      <el-button size="mini" type="primary" icon="el-icon-search" @click="toQuery">搜索</el-button>
      <el-button v-permission="['ADMIN','COURSE_ALL','COURSE_CREATE']"
        size="mini"
        type="primary"
        icon="el-icon-plus"
        @click="add">新增</el-button>
      <eForm ref="form" :is-add="true" />
    </el-form-item>
  </el-form>
</template>

<script>
import eForm from './form'
export default {
  components: { eForm },
  props: {
    query: {
      type: Object,
      required: true
    }
  },
  data() {
    return {}
  },
  methods: {
    toQuery() {
      this.$parent.page = 1
      this.$parent.init()
    },
    add() {
      this.$refs.form.listCategory()
      this.$refs.form.dialog = true
    }
  }
}
</script>
